package com.yixun.qfbao.model.enums;

import org.apache.commons.lang.StringUtils;

public enum ReceiveIntentionErrorCodeEnum {
    CODE_000("000","报备成功","报备成功，该报备以为待审"),
    CODE_001("001","重复报备","报备无效，该楼盘下已有此客户报备记录，无法重复报备"),
    CODE_002("002","客户处在保护期","报备无效，该楼盘下此客户的报备仍处在保护期内，无法重复报备"),
    CODE_003("003","M2已有客户","报备无效，M2案场管理中该楼盘已有此客户记录，无法重复报备"),
    CODE_004("004","客户已到访","报备无效，此客户已到访该楼盘，无法再次报备"),
    CODE_005("005","客户已在交易中","报备无效，此客户已到在交易中，无法再次报备"),
    CODE_006("006","小于最短报备时间","报备无效，无法临时报备"),
    CODE_007("007","逾期被禁止报备","报备无效，根据设置的逾期规则，无法进行报备，请联系管理员询问"),
    CODE_008("008","期望带看时间不能早于当前时间","报备无效,期望带看时间不能早于当前时间"),
    CODE_009("009","报备免审","报备免审,该报备以为未到访"),
    CODE_FILE("100","通用异常","通用异常");

    private final String no;
    private final String des;
    private final String msg;

    public String getNo() {
        return no;
    }

    public String getDes() {
        return des;
    }

    public String getMsg() {
        return msg;
    }

    ReceiveIntentionErrorCodeEnum(String no, String des, String msg){
        this.no = no;
        this.des = des;
        this.msg = msg;
    }
    public static ReceiveIntentionErrorCodeEnum getByDescription(String des) {
        if(StringUtils.isBlank(des)){
            return null;
        }
        for (ReceiveIntentionErrorCodeEnum menum : values()) {
            if (menum.getDes().equals(des)) {
                return menum;
            }
        }
        return null;
    }
    public static ReceiveIntentionErrorCodeEnum getByNo(String no) {
        if(StringUtils.isBlank(no)){
            return null;
        }
        for (ReceiveIntentionErrorCodeEnum menum : values()) {
            if (menum.getNo().equals(no)) {
                return menum;
            }
        }
        return null;
    }
}
